<template>
	<view class="index" v-if="pageLoad">
		<view class="uni-list">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(item,key2) in ranks" :key="key2" @click="goTo(item)">
				<view class="uni-list-cell-navigate uni-navigate-right uni-media-list ">

					<image class="uni-media-list-logo" :src="item.imgUrl"></image>
					<view class="uni-media-list-body" >
						{{item.text}}
					</view>
				</view>
			</view>
		</view>
		<view class="uni-list">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(item,key3) in plays" :key="key3" @click="goTo(item)">
				<view class="uni-list-cell-navigate uni-navigate-right uni-media-list ">
					<image class="uni-media-list-logo" :src="item.imgUrl"></image>
					<view class="uni-media-list-body" >
						{{item.text}}
					</view>
				</view>
			</view>
		</view>
		<view class="uni-list">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(item,key4) in others" :key="key4" @click="goTo(item)">
				<view class="uni-list-cell-navigate uni-navigate-right uni-media-list ">

					<image class="uni-media-list-logo" :src="item.imgUrl"></image>
					<view class="uni-media-list-body" >
						{{item.text}}
					</view>
				</view>
			</view>
		</view>
		<view class="btn-row">
				<button type="primary" class="feedback-submit" @tap="exitLogin" v-if="hasLogin">退出登录</button>
		</view>
	</view>
	
</template>

<script>
	import {
		mapGetters,
			mapState,
			mapMutations
	} from 'vuex';
	
	export default {
		data() {
			return {
				titleText: "发现",
				statusColor: "#7C4BF9",
				showLeftButton: false,
				pageLoad: false,
				ranks:[
					{
						text:'账户安全',	
						imgUrl: '../../static/image/my/setting/account.png',
						navigatePage: '/pages/my/settingpage/securityInfo',
						navigateValue: 0
					},
// 					{
// 						text:'贡献榜单',	
// 						imgUrl: '../../static/image/found/contribute.png',
// 						navigatePage: 'rank/index',
// 						navigateValue: 1
// 					},
				],
				plays: [
					{
						text:'消息通知',	
						imgUrl: '../../static/image/my/setting/notify.png',
						navigatePage: '/pages/my/settingpage/notify',
						navigateValue: 0
					},
					{
						text:'隐私保护',	
						imgUrl: '../../static/image/my/setting/privacy.png',
						navigatePage: '/pages/my/settingpage/privacy',
						navigateValue: 0
					},
					{
						text:'黑名单',	
						imgUrl: '../../static/image/my/setting/black.png',
						navigatePage: '/pages/my/settingpage/blacks',
						navigateValue: 0
					}
				],
				others: [
					{
						text:'关于我们',	
						imgUrl: '../../static/image/my/setting/about.png',
						navigatePage: '/pages/my/settingpage/about',
						navigateValue: 0
					},
					{
						text:'版本更新',	
						imgUrl: '../../static/image/my/setting/version.png',
						navigatePage: 'upgrade',
						navigateValue: 0
					}
				],
			}
		},
		computed: {
			...mapGetters(
				["hasLogin"],
			),
		},
		onLoad: function () {
			this.pageLoad = true;
		},
		onUnload:function(){
		},
		methods: {
			
			goTo: function(e){
				//#ifdef APP-PLUS
				if(e.navigatePage == 'upgrade') {
					this.upgrade();
					return;
				}
				//#endif
				uni.navigateTo({
					url: e.navigatePage+"?navigateValue=" + e.navigateValue
				})
			},
			exitLogin: function() {
				var that = this;
				uni.showModal({
					title: '提示',
					content: '确定要退出登录吗？',
					success: function(res) {
						if (res.confirm) {
							that.$store.dispatch("LogOut").then( response => {
								that.$store.dispatch("connect").then(response => {
										setTimeout(()=>{  //定时器设置每秒递减
											uni.navigateBack();
										},60)
								});
								
							}).catch(err => {
								uni.showModal({
									title:"提示",
									content:"请重新推出登录，谢谢"
								})
							})
							
						}
					}
				})
				
			},
			//#ifdef APP-PLUS
			upgrade() {
				uni.showModal({
					content:"暂无版本升级"
				})
// 				uni.request({
// 					url: server,
// 					data: req,
// 					success: (res) => {
// 						console.log("success", res);
// 						if (res.statusCode == 200 && res.data.isUpdate) {
// 							let openUrl = plus.os.name === 'iOS' ? res.data.iOS : res.data.Android;
// 							uni.showModal({ //提醒用户更新
// 								title: '更新提示',
// 								content: res.data.note ? res.data.note : '是否选择更新',
// 								success: (res) => {
// 									if (res.confirm) {
// 										plus.runtime.openURL(openUrl);
// 									}
// 								}
// 							})
// 						}
// 					}
// 				})
			}
			//#endif
			
		}
	}
</script>

<style>
	@import "../../common/uni.css";
	
	
	.index {
		display: flex;
		flex: 1;
		flex-direction: column;
		overflow: hidden;
		height: 100%;
	}

	.index-bd {
		
		width: 750px;
		height: 100%;
	}
	.uni-list {
		width: 710px !important;
		margin: 20px;
		border-radius: 15px;
	}
	
	.uni-media-list-logo {
		width: 50px !important;
		height: 50px !important;
	}
	
	.uni-media-list-body {
		height: 36px;
		line-height: 36px;
		font-size: 28px !important;
		justify-content: space-around;
	}
	
	.uni-media-list-text-top {
		height: 50px !important;
		
		overflow: hidden;
	}

	.feedback-submit {
		background: #7C4BF9 !important;
	}
</style>
